package Ping;

import java.net.InetAddress;

/**
 * @description:
 * @author: cyy
 **/
public class ping {
    public static void main(String[] args) {
        try {
            long start = System.currentTimeMillis();

            String ipAddress = "192.168.0.164";
            InetAddress inet = InetAddress.getByName(ipAddress);
            boolean reachable = inet.isReachable(3000);
            System.out.println("Sending Ping Request to " + ipAddress);
            System.out.println(reachable ? "Host is reachable" : "Host is NOT reachable");

            long end = System.currentTimeMillis();
            long l = end - start;
            System.out.println("jiange :" + l +"毫秒");


            /*
            ipAddress = "220.181.112.242";
            inet = InetAddress.getByName(ipAddress);

            System.out.println("Sending Ping Request to " + ipAddress);
            System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");*/
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
